package com.itheima.test;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.junit.Test;

public class StandardProxy {
	
	@Test
	public void test(){
		StandardDao proxy = (StandardDao) Proxy.newProxyInstance(StandardDao.class.getClassLoader(),  new Class[]{StandardDao.class}, new InvocationHandler() {
			
			@Override
			public Object invoke(Object proxy, Method method, Object[] args)
					throws Throwable {
					
				Query annotation = method.getAnnotation(Query.class);
				String value = annotation.value();
				System.out.println(value);
				return null;
			}
		});
		
		proxy.findname("zhangsan");
	}
}
